EXERCISE 2: This code is repetitive. We wrote the same commands SIX times! Let's refactor!

  • The code on lines 8, 9, and 10 repeats a bunch, so those lines are what we should reuse.
  • In SUBJECT, click on and copy and paste lines 8, 9, and 10 inside a new custom block.
  • Then, click Run, Submit, and Next to continue.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)